#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void ShellSort(int* a, int n)
{
	int i = 0;
	//int gap=n/2  //log2(N)
	int gap = n / 3 + 1;   //log3(N)
	for (i = 0; i < n - gap; i++)
	{
		int end = i;
		int tmp = a[end + gap];
		while (end >= 0)
		{
			if (a[end] > tmp)
			{
				a[end + gap] = a[end];
				end-=gap;
			}
			else
			{
				break;
			}
		}
		a[end + gap] = tmp;
	}
}
int main()
{
	int arr[10] = { 5,8,9,1,4,7,6,3,10,2 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	ShellSort(arr, sz);
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}